package com.jof.framework.hmc.domain;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.thoughtworks.xstream.annotations.XStreamAlias;

/**
 * @author zhangtao
 * 邮件信息
 */
@XStreamAlias("email")
public class Email extends MessageModule {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8102802427751323837L;
	public final static String IS_HTML="ISHTML";
	/**
	 * 发送人姓名
	 */
	@XStreamAlias("from")
	private Recipient sender;

	/**
	 * 收件人地址列表
	 */
	@XStreamAlias("to")
	private List<Recipient> toRecipient;

	/**
	 * 抄送人邮件地址列表
	 */
	@XStreamAlias("cc")
	private List<Recipient> ccRecipient;

	/**
	 * 秘密抄送邮件地址列表
	 */
	@XStreamAlias("bcc")
	private List<Recipient> bccRecipient;

	/**
	 * 邮件主题
	 */
	@XStreamAlias("subject")
	private String subject;

	/**
	 * 邮件内容
	 */
	@XStreamAlias("content")
	private String bodyContent;

	/**
	 * HTML格式的邮件内容
	 */
	@XStreamAlias("html_content")
	private String htmlBodyContent;

	/**
	 * 发送时间
	 */
	@XStreamAlias("send_date")
	private Date systemSendDate;

	/**
	 * 邮件附件
	 */
	@XStreamAlias("attachment")
	private Map<String, byte[]> attachment;

	/**
	 * 紧急程度
	 */
	@XStreamAlias("priority")
	private Priority priority;

	public enum Priority {
		HIGH(1), NORMAL(3), LOW(5);
		private int id;

		private Priority(int id) {
			this.id = id;
		}

		public int getId() {
			return id;
		}

	}

	public Recipient getSender() {
		return sender;
	}

	public void setSender(Recipient sender) {
		this.sender = sender;
	}

	public List<Recipient> getToRecipient() {
		return toRecipient;
	}

	public void setToRecipient(List<Recipient> toRecipient) {
		this.toRecipient = toRecipient;
	}

	public List<Recipient> getCcRecipient() {
		return ccRecipient;
	}

	public void setCcRecipient(List<Recipient> ccRecipient) {
		this.ccRecipient = ccRecipient;
	}

	public List<Recipient> getBccRecipient() {
		return bccRecipient;
	}

	public void setBccRecipient(List<Recipient> bccRecipient) {
		this.bccRecipient = bccRecipient;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getBodyContent() {
		return bodyContent;
	}

	/**
	 * @param bodyContent
	 * @param isHTML: True-Content is HTML, False-Content is not HTML
	 * 
	 */
	public void setBodyContent(String bodyContent,boolean isHTML) {
		if(isHTML){
			this.htmlBodyContent=IS_HTML;
		}
		this.bodyContent = bodyContent;
	}

	public String getHtmlBodyContent() {
		return htmlBodyContent;
	}

	public Date getSystemSendDate() {
		return systemSendDate;
	}

	public void setSystemSendDate(Date systemSendDate) {
		this.systemSendDate = systemSendDate;
	}

	public Map<String, byte[]> getAttachment() {
		return attachment;
	}

	public void setAttachment(Map<String, byte[]> attachment) {
		this.attachment = attachment;
	}

	public Priority getPriority() {
		return priority;
	}

	public void setPriority(Priority priority) {
		this.priority = priority;
	}

	
	public String toString() {
		return "Email [sender=" + sender + ", toRecipient=" + toRecipient + ", ccRecipient=" + ccRecipient
				+ ", bccRecipient=" + bccRecipient + ", subject=" + subject + ", bodyContent=" + bodyContent
				+ ", htmlBodyContent=" + htmlBodyContent + ", systemSendDate=" + systemSendDate + ", attachment="
				+ attachment + ", priority=" + priority + "]";
	}

}
